home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / doc / homepage / tutorials / lesson5 / musical.java < prev    next >
Text File  |  1996-08-21  |  771b  |  36 lines

  1. /*
  2.    musical.java : source for sound tutorial
  3.    Written By : Jai Natarajan
  4.                 Sony Pictures Imageworks
  5. */
  6. import vrml.*;
  7. import vs.*;
  8.  
  9. public class musical extends Script {
  10.   
  11.   SFTime musicOn = (SFTime)getEventOut("musicOn");
  12.   SFTime musicOff = (SFTime)getEventOut("musicOff");
  13.   
  14.   boolean musicPlaying = false;
  15.  
  16.   public musical() { }
  17.  
  18.   public void clicked(ConstSFBool ev, ConstSFTime time) {
  19.  
  20.     double now = time.getValue();  
  21.   
  22.     if(ev.getValue() == true) {
  23.       return;
  24.     }
  25.     else {  
  26.        if(!musicPlaying) {  // we need to switch it on
  27.          musicOn.setValue(now);
  28.        }
  29.        else { // switch it off
  30.          musicOff.setValue(now);
  31.        }
  32.        musicPlaying = !musicPlaying;
  33.     }
  34.   }
  35. }
  36.